<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN"> 
<head>
	<!-- INCLUDE meta.html -->
    <script src="js/jquery/jquery.js" ></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.image_description
{
	width:200px;
	height:84px;
}
.image_tag
{
	width:160px;
	height:84px;
}

.image_title,.image_author,.image_shotdate
{
	width:150px;
}
.image_category
{
	width:156px;
}
.refresh_btn
{
	cursor:pointer;
}
</style>
<script src="js/jquery/jquery2.js" ></script>
<script src="js/jquery/ui.datepicker.js" ></script>
<script src="js/jquery/ui.datepicker-zh-CN.js"></script>
<link rel="stylesheet" href="js/jquery/ui.datepicker.css" media="screen" />
</head>
<body>
<div class='main'>

<div class="headerdiv">
	<!-- INCLUDE header.html -->
</div>

<div id='content'>
	<div id='left'>
    	<div style="margin:10px;margin-top:30px;">
        	<ul>
				<li><a href="{last_list_page}">{RETURN_TO_PHOTO}</a></li>
            </ul>
    		
        </div>
    </div>
    <div id='maindiv'>
    	<div class="description">
			{page_description}
        </div>
        
        <!-- IF err_msg -->
        <div class="err_msg pad">
        	{err_msg}
        </div>
        <!-- ENDIF -->
        
        <!-- IF success_msg -->
        <div class="success_msg pad">
        	{success_msg}
        </div>
        <!-- ENDIF -->
        
	<div class="real_content">
   	<!-- IF image_array.0.status="1" -->
	<form method="POST" action="admin.php?p=photo_edit&m=reedit" onsubmit="checkform(this); return false;">
	<!-- ELSE -->
	<form method="POST" action="admin.php?p=photo_edit&m=update" onsubmit="checkform(this); return false;">
	<!-- ENDIF -->
    	<div class="submit_buttons">
        	<button onclick="return reset_form()">{BUTTON_RESET}</button>&nbsp;<input type="submit" value="{BUTTON_SUBMIT}" />
        </div>
    	<table cellpadding="0" cellspacing="4" border="0">
        	<thead>
            	<th>{PHOTO_ICON}</th>
                <th>{PHOTO_TITLE}</th>
                <th>{PHOTO_TAG}</th>
                <th>{PHOTO_DESCRIPTION}</th>
                <th>{PHOTO_OPTIONS}</th>
        	</thead>
        	<tbody>
            	<!-- BEGIN image_array -->
                <tr>
                	<td width="140" align="center">
                    	<a href="javascript:preview('{big}')"><img src="{small}" /></a><input type="hidden" name="photo[{i}][photo_id]" value="{photo_id}" />
                    </td>
                    <td valign="bottom" style="width:;">
					<div style="width:;">
						<table cellspacing="0" cellpadding="0" border="0">
							<tr>
								<td>{PHOTO_CATEGORY}:</td>
								<td><select name="photo[{i}][category_id]" id='category_id_{i}' selectedd_option="{category_id}" value='{category_id}' class="image_category">
							{parent.select_options}
								</select></td>
								<td><img src="{parent.images}/refresh.gif" class="refresh_btn" syc_id="category_id_{i}" /></td>
							</tr>
							<tr>
								<td>{PHOTO_TITLE}:</td>
								<td><input type="text" name="photo[{i}][title]" id="title_{i}" class="image_title" value="{title}" /></td>
								<td><img src="{parent.images}/refresh.gif" class="refresh_btn" syc_id="title_{i}" /></td>
							</tr>
							<tr>
								<td>{PHOTO_AUTHOR}:</td>
								<td><input type="text" name="photo[{i}][author]" id="author_{i}" class="image_author" value="{author}" /></td>
								<td><img src="{parent.images}/refresh.gif" class="refresh_btn" syc_id="author_{i}" /></td>
							</tr>
							<tr>
								<td>{PHOTO_SHOTDATE}:</td>
								<td><input type="text" name="photo[{i}][shotdate]" id="shotdate_{i}" class="image_shotdate" value="{shotdate}" /></td>
								<td><img src="{parent.images}/refresh.gif" class="refresh_btn" syc_id="shotdate_{i}" /></td>
							</tr>
						</table>
					</div>
                    </td>
                    <td valign="bottom">
                    	{PHOTO_TAG_SUGGEST}<img src="{parent.images}/refresh.gif" class="refresh_btn" syc_id="tag_{i}" /><br /><textarea name="photo[{i}][tag]" id="tag_{i}" class="image_tag" >{tag}</textarea>
                    </td>
                    <td valign="bottom">
                    	{PHOTO_DESCRIPTION_SUGGEST}<img src="{parent.images}/refresh.gif" class="refresh_btn" syc_id="description_{i}" /><br /><textarea name="photo[{i}][description]" id="description_{i}" class="image_description" >{description}</textarea>
                    </td>
                    <td>
                    	<button onclick="return copy_to_all({i})" style="height:50px;">{COPY_TO_OTHERS}</button>
                    </td>
                </tr>
                <!-- END -->
        	</tbody>
        </table>
    	<div class="submit_buttons">
        	<button onclick="return reset_form()">{BUTTON_RESET}</button>&nbsp;<input type="submit" value="{BUTTON_SUBMIT}" />
        </div>
     </form>
     </div>
   </div>
</div>
<script>
function checkform(f)
{
	var stopsubmit = false;
	$(f).find('[id^=tag_]').add('[id^=title_]').each(function()
	{
		if ($(this).val() == '')
		{
			stopsubmit = true;
			$(this).addClass('alert');
		}
		else
		{
			$(this).removeClass('alert');
		}
	});

	if (stopsubmit)
	{
		alert('{TITLE_AND_TAG_EMPTY}');
		return;
	}
	else
	{
		f.submit();
	}
}


function copy_to_all(i)
{
	//需要同步的 input 对应的id
	var inputs = ['title','tag','description','shotdate','author','category_id'];
	for(var j in inputs)
	{
		var key = inputs[j];
		$('[id^='+key+'_]').val($('#'+key+'_'+i).val());
	}
	return false;
}

function reset_form()
{
	var f = document.forms[0];
	f.reset();
	//选择默认的分类选项
	$('[id^=category_id_]').each(function(i)
	{
		$('#category_id_'+i).val($('#category_id_'+i).attr('selectedd_option'));
	});
	return false;
}

$(function() 
{
	//选择默认的分类选项
	$('[id^=category_id_]').each(function(i)
	{
		$('#category_id_'+i).val($('#category_id_'+i).attr('selectedd_option'));
	});
	
	if ($('[id^=category_id_]').length > 1)
	{
		//定义同步按钮的点击事件
		$('.refresh_btn').bind('click',function()
		{
			var orig_syc_id = this.getAttribute('syc_id');
			syc_id = orig_syc_id.replace(/\d/g,'');
			$('[id^='+syc_id+']').val( $('#'+orig_syc_id).val() );
		});
		//为同步按钮附加 alt 属性
		$('.refresh_btn').attr('title','{ITEM_COPY_TO_ALL}');
	}
	else
	{
		$('.refresh_btn').each(function()
		{
			this.style.display  = 'none';
		});
	}
	
	
	$("[id^=shotdate_]").datepicker();

});
load('view/admin/js/photo.js');
</script>
<!-- INCLUDE footer.html -->

</div>
</body>
</html>
